package com.hjw.inheritance.junit;

import com.hjw.inheritance.java.Person;
import com.hjw.inheritance.java.Teacher;

import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author hjwStrart
 * @create 2022-01-12 10:39
 */
public class Test1 {
    public static void main(String[] args) {
////        teacher是person的子类
//        Person teacher = new Teacher();
//        System.out.println(teacher.name);//null
//        teacher.name = "tt";
//        System.out.println(teacher.name);//tt
        Random rand = new Random();
        StringBuilder sbu = new StringBuilder("1");
        String[] ops = new String[]{"", "+", "-"};
         for (int i = 2; i <= 9; i++) {
             sbu.append(ops[rand.nextInt(3)].concat(String.valueOf(i)));
         }
         System.out.printf("%s%n", sbu.toString());
         String str = "123-4-5-67+8-9";
         //使用正则表达式搜索数字 "-?\\d+"
        Pattern p = Pattern.compile("-{0,1}[0-9]{1,}");
        Matcher m = p.matcher(str);
        int sum = 0;
        while (m.find()) {
            int num = Integer.parseInt(m.group());
            System.out.println(num);
            sum += num;
        }
        System.out.println(sum);
    }
}
